/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Application;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import Maps.GoogleMaps;

/**
 * @author Stanley
 */
public class MainMidlet extends MIDlet {
    private boolean midletPaused = false;
    
    // Display 
    private Display display;
    // Screens
    private Home home;
    private Options options;
    private Search search;
    private FindPath findPath;
    private MapTypes mapType;
    private FindCoordinates findCoordinates;
    
    // constructor
    public MainMidlet() throws Exception {
        // get the display
        display = Display.getDisplay(this);
        // construct the screens
        home = new Home(this);
        options = new Options(this);
        search = new Search(this);
        findPath = new FindPath(this);
        mapType = new MapTypes(this);
        findCoordinates = new FindCoordinates(this);
    }
    
    // show home screen
    public void homeShow() {
        display.setCurrent(getHome());
    }
    
    public void optionsShow() {
        display.setCurrent(options);
    }
    
    public void searchShow() {
        display.setCurrent(search);
    }
    
    public void findPathShow() {
        display.setCurrent(findPath);
    }
    
    public void mapTypeShow() {
        display.setCurrent(mapType);
    }
    
    public void findCoordinatesShow(){
        display.setCurrent(findCoordinates);
    }
    
    public void startApp() {
        homeShow();
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
        System.gc();
        notifyDestroyed();
    }
    
    public void resumeMIDlet() {
    }
    
    public void initialize(){
    }
    
    public void startMIDlet() {
    }
    
    public void switchDisplayable(Alert alert, Displayable nexDisplayable) {
        Display display = getDisplay();
        if (alert == null) {
            display.setCurrent(nexDisplayable);
        } else {
            display.setCurrent(alert, nexDisplayable);
        }
    }
    
    public Display getDisplay() {
        return Display.getDisplay(this);
    }
    
    public void exitMIDlet() {
        destroyApp(true);
    }

    /**
     * @return the home
     */
    public Home getHome() {
        return home;
    }

    /**
     * @param home the home to set
     */
    public void setHome(Home home) {
        this.home = home;
    }
}
